package main

import (
	"fmt"
	"learngo/tree"
)

func main() {
	var root tree.Node
	//fmt.Println(root)

	root = tree.Node{Value:3}
	root.Left = &tree.Node{}
	root.Right = &tree.Node{5, nil, nil }
	root.Right.Left = new(tree.Node)
	root.Left.Right = tree.CreateNode(2)

	fmt.Println()
	root.Print()
	root.Right.Left.SetValue(4)
	root.Right.Left.Print()
	fmt.Println()

	fmt.Println("+++++++++++")

	root.Traversal()

	nodeCount := 0
	root.TraversalFunc(func(node *tree.Node){
		nodeCount++
	})
	fmt.Println("Node Count:", nodeCount)

	c := root.TraverseWithChannel()
	maxNode := 0
	for node := range c {
		if node.Value > maxNode {
			maxNode = node.Value
		}
	}

	fmt.Println("Max node value:", maxNode)
}

